<template>
    <div>
        <button @click="getStory">Q查询 访问次数大于3的所有小说</button>
        <table align="center" width="400px" border="1">
            <tr>
                <td>标题</td>
                <td>权限</td>
                <td>访问次数</td>
            </tr>
            <tr v-for="story in storyList">
                <td>{{story.title}}</td>
                <td>{{story.level | level}}</td>
                <td>{{story.num}}</td>
            </tr>
        </table>
        <table align="center" width="800px" border="1">
            <tr>
                <td>记录编号</td>
                <td>用户</td>
                <td>标题</td>
                <td>开始时间</td>
                <td>结束时间</td>
                <td>阅读时间</td>
                <td>获得金额</td>
            </tr>
            <tr v-for="record in recordList">
                <td>{{record.id}}</td>
                <td>{{record.user.username}}</td>
                <td>{{record.story.title}}</td>
                <td>{{record.start}}</td>
                <td>{{record.end}}</td>
                <td>{{record.time}}</td>
                <td>{{record.money}}</td>
            </tr>
        </table>
    </div>
</template>

<script>
    export default {
        name: "seek_story",
        data() {
            return {
                storyList: [],
                recordList: [],
            }
        },
        methods: {
            getStory() {
                this.$axios({
                    url: 'story/record/',
                    params: {
                        num: 3
                    }
                }).then(resp => {
                    console.log(resp.data)
                    this.storyList = resp.data.story_list;
                    this.recordList = resp.data.record_list;
                })
            }
        },
        computed: {},
        filters: {
            level(x) {
                if (x == 0) {
                    return '普通'
                } else {
                    return 'VIP'
                }
            }
        },
        watch: {},
    }
</script>

<style scoped>

</style>
